package com.fly.demo.controller;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 
 * IndexController
 * 
 * @author 00fly
 * @version [版本号, 2018-11-06]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Controller
public class IndexController
{
    @Autowired
    ApplicationContext applicationContext;
    
    /**
     * 首页
     * 
     * @param model
     * @return
     * @see [类、类#方法、类#成员]
     */
    @RequestMapping("/")
    public String index(Model model)
    {
        return "index";
    }
    
    /**
     * toLogin
     * 
     * @return
     * @see [类、类#方法、类#成员]
     */
    @GetMapping("/toLogin")
    public String toLogin()
    {
        return "loginForm";
    }
    
    @PostMapping("/login")
    public String login(String userName, String passWord)
    {
        if (StringUtils.isAnyBlank(userName, passWord))
        {
            return "loginForm";
        }
        return "index";
    }
}
